#include<cstring>
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;
const int maxn=1<<21;
int EXP[maxn],A[maxn],D[maxn],HP[maxn],LE[maxn];
int a[21],d[21],hp[21],exp[21];
int n,da,dd,dhp;
int max(int x,int y)
{
	return x>y?x:y;
}
int main()
{
	EXP[0]=0;LE[0]=1;
	while(~scanf("%d%d%d%d%d%d",&A[0],&D[0],&HP[0],&da,&dd,&dhp))
	{
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			string name;
			cin>>name;
			scanf("%d%d%d%d",&a[i],&d[i],&hp[i],&exp[i]);
		}
		int state=(1<<n)-1;
		for(int i=1;i<=state;i++)
		{
			HP[i]=0;
			for(int j=1;j<=n;j++)
			{
				int s=1<<(j-1);
				if(i==s)
				{
					int lbhp=HP[0],xhp=hp[j];
					while(lbhp>0&&xhp>0)
					{
						xhp-=max(1,A[0]-d[j]);
						if(xhp<=0)break;
						lbhp-=max(1,a[j]-D[0]);
					}
					if(lbhp<=0)
					{
						HP[i]=-1;
						break;
					}
					else
					{
						HP[i]=lbhp;
						EXP[i]=EXP[0]+exp[j];
						LE[i]=LE[0];
						A[i]=A[0];
						D[i]=D[0];
						if(EXP[i]>=100*LE[0])
						{
							LE[i]++;
							A[i]+=da;
							D[i]+=dd;
							HP[i]+=dhp;
						}
						break;
					}				
				}
				if( (i&s) ==0)continue;
				int lbhp=HP[i-s],xhp=hp[j];
				if(lbhp<=0)continue;
				while(lbhp>0&&xhp>0)
				{
					xhp-=max(1,A[i-s]-d[j]);
					if(xhp<=0)break;
					lbhp-=max(1,a[j]-D[i-s]);
				}
				if(lbhp<=0)
				{
					if(HP[i]==0)HP[i]=-1;
					continue;
				}
				else
				{
					if(EXP[i-s]+exp[j]>=100*LE[i-s])lbhp+=dhp;
					if(lbhp>HP[i])
					{
						HP[i]=lbhp;
						EXP[i]=EXP[i-s]+exp[j];
						LE[i]=LE[i-s];
						A[i]=A[i-s];
						D[i]=D[i-s];
						if(EXP[i]>=100*LE[i-s])
						{
							LE[i]++;
							A[i]+=da;
							D[i]+=dd;
						}						
					}		
				}
			}
		}
		if(HP[state]>0)cout<<HP[state]<<endl;
		else cout<<"Poor LvBu,his period was gone."<<endl;
	}
	return 0;
}


